package model;

import java.util.Date;

public class ModelID {

  private Long id;
  private Date timestamp;
  private transient Termin termin;

  public Termin getTermin() {
    return termin;
  }

  public void setTermin(Termin termin) {
    if (termin == null)
      throw new IllegalArgumentException("Termin darf nicht null sein!");
    this.termin = termin;

  }

  public void removeTermin() {
    this.termin = null;
  }

  public void setID(Long id) {
    if (id == null || id < 1)
      throw new IllegalArgumentException("ID darf nicht null sein!");

    this.id = id;
  }

  public void idLoeschen() {
    this.id = null;
  }

  public Long getId() {
    if (id == null)
      return new Long(-999);
    return id;
  }

  public void setTimestamp(Date timeStamp) {
    if (timeStamp == null)
      throw new IllegalArgumentException("timestamp darf nicht null sein!");

    this.timestamp = (Date) timeStamp.clone();
  }

  public Date getTimestamp() {
    if (timestamp == null)
      return null;
    return (Date) timestamp.clone();
  }

  public boolean neu() {
    return id == null;
  }

  @Override
  public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((id == null) ? 0 : id.hashCode());
    result = prime * result + ((timestamp == null) ? 0 : timestamp.hashCode());
    return result;
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj)
      return true;
    if (obj == null)
      return false;
    if (getClass() != obj.getClass())
      return false;
    ModelID other = (ModelID) obj;
    if (id == null) {
      if (other.id != null)
        return false;
    } else if (!id.equals(other.id))
      return false;
    if (timestamp == null) {
      if (other.timestamp != null)
        return false;
    } else if (!timestamp.equals(other.timestamp))
      return false;
    return true;
  }


  

}
